var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((n.prototype = e.prototype), new n()));
      };
    })(),
  DaBiPingView = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        WebSocketService.addListener({
          caller: i,
          code: 20302,
          method: i.onLoadDaBiPingActData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 20303,
          method: i.onLoadDaBiPingRankRewardData,
        }),
        i.btn_dabiping_more.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickMoreDBPDataAction
        ),
        i.btn_dbpback.on(Laya.Event.CLICK, i, i.onCancleBtnClickFn),
        i
      );
    }
    return (
      __extends(i, t),
      (i.openDaBiPing = function () {
        return (
          null == this.dabipingV && (this.dabipingV = new i()),
          WebSocketService.send({ c: 20302 }),
          WebSocketService.send({ c: 20303 }),
          this.dabipingV
        );
      }),
      (i.prototype.onLoadDaBiPingActData = function (t) {
        var i = t.data;
        if (i && i.length > 0) {
          var e = i[0];
          (this.label_dabiping_coutdownTime.text = Utils.restTimeCount(
            e.endTime,
            "day_hou_min"
          )),
            (this.label_dabiping_myScore.text = e.score + "积分"),
            (this.label_dabiping_myseq.text = e.rank);
        }
      }),
      (i.prototype.timerCountDownMatchFn = function () {
        this.timeDiff--;
        var t = 0,
          i = 0,
          e = 0,
          n = 0;
        (t = Math.floor(this.timeDiff / 86400)),
          (i = Math.floor((this.timeDiff % 86400) / 3600)),
          (e = Math.floor((this.timeDiff % 3600) / 60)),
          (n = Math.floor(this.timeDiff % 60)),
          t <= 0 && i <= 0 && e <= 0 && n <= 1
            ? (Laya.timer.clear(this, this.timerCountDownMatchFn),
              (this.label_dabiping_coutdownTime.text = "本轮活动结束"))
            : (this.label_dabiping_coutdownTime.text =
                Utils.timeCountDown(this.timeDiff) + "");
      }),
      (i.prototype.onLoadDaBiPingRankRewardData = function (t) {
        if (t.data) {
          var i = t.data;
          if (i && i.length > 0) {
            (this.tempArray = t.data), (this.list_dabiping_reward.visible = !0);
            var e = void 0;
            this.tempArray = [];
            for (var n = 0; n < i.length; n++) {
              var o = i[n];
              (e = {
                item0: { text: this.dealSeqIndex(n) },
                item1: { text: o.goodsName + "X" + o.count },
              }),
                this.tempArray.push(e);
            }
            this.list_dabiping_reward.dataSource = this.tempArray;
          }
        }
      }),
      (i.prototype.dealSeqIndex = function (t) {
        var i = "";
        return (
          0 == t
            ? (i = "第1名:")
            : 1 == t
            ? (i = "第2名:")
            : 2 == t
            ? (i = "第3名:")
            : 3 == t
            ? (i = "第4-6名:")
            : 4 == t && (i = "第7-10名:"),
          i
        );
      }),
      (i.prototype.onDidClickMoreDBPDataAction = function () {
        var t = DaBiPingRankListView.openDaBiPingRankView();
        (t.y = 35), Laya.stage.addChild(t);
      }),
      (i.prototype.onCancleBtnClickFn = function () {
        this.removeSelf();
      }),
      i
    );
  })(ui.ActivityController.DaBiPingViewUI);
